package com.cskaoyan.utils;

import java.util.regex.Pattern;

public class StringUtils {
    /**
     * 字符串为空字符串 为空返回true
     */
    public static boolean isEmpty(String s){
        return s == null || "".equals(s.trim());
    }

    /**
     * 字符串是否是数字 是数字或空返回true
     */

    public static boolean isNumeric(String str){
        Pattern pattern = Pattern.compile("[0-9]*");
        return pattern.matcher(str).matches();
    }

    // 字符串转数组[1,2]
    public static String[] toStringArray(String str){
        if(!isNumeric(str)){
            str = str.substring(1, str.length()-1);
        }
        return str.split(",");
    }
}
